package com.gmq.common;

import org.springframework.stereotype.Component;

//基于threadLocal工具类,用户保存和获取当前登录用户ID,每个线程的threadLocal都不同，所以不用担心重复的问题
@Component
public class BaseContext {
    private ThreadLocal<Long> threadLocal=new ThreadLocal<>();

    //设置数据
    public void setThreadLocal(Long id){
        threadLocal.set(id);
    }

    //获取数据
    public Long getThreadLocal(){
        return threadLocal.get();
    }
}
